package com.blog.back.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.blog.entity.ArticleInfoEntity;
import com.blog.back.service.ArticleInfoService;
import com.blog.utils.PageUtils;
import com.blog.utils.R;



/**
 * 
 *
 * @author codedorado
 * @email codedorado@foxmail.com
 * @date 2020-08-15 15:26:05
 */
@RestController
@RequestMapping("back/articleinfo")
public class ArticleInfoController {
    @Autowired
    private ArticleInfoService articleInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("back:articleinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = articleInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{infoId}")
    // @RequiresPermissions("back:articleinfo:info")
    public R info(@PathVariable("infoId") Long infoId){
		ArticleInfoEntity articleInfo = articleInfoService.getById(infoId);

        return R.ok().put("articleInfo", articleInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("back:articleinfo:save")
    public R save(@RequestBody ArticleInfoEntity articleInfo){
		articleInfoService.save(articleInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("back:articleinfo:update")
    public R update(@RequestBody ArticleInfoEntity articleInfo){
		articleInfoService.updateById(articleInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("back:articleinfo:delete")
    public R delete(@RequestBody Long[] infoIds){
		articleInfoService.removeByIds(Arrays.asList(infoIds));

        return R.ok();
    }

}
